<template>
  <h4>x的值:{{ x.y }}</h4>
  <button type="" @click="x.y++">点击x值+1</button>
  <hr />
  <h4>{{ person }}</h4>
  <h2>{{ `姓名：${name}` }}</h2>
  <h2>年龄： {{ age }}</h2>
  <h2>薪水：{{ job.j1.salary }}K</h2>
  <button type="" @click="name += '~'">修改姓名</button>
  <button type="" @click="age++">增长年龄</button>
  <button type="" @click="job.j1.salary++">涨薪</button>
</template>

<script>
// ref, reactive,
import {  toRefs, shallowReactive, shallowRef } from "vue";
export default {
  name: "App",
  setup() {
    // let person = shallowReactive({ 只考虑第一层数据的响应式

    let person = shallowReactive({
      name: "张三",
      age: 18,
      job: {
        j1: {
          salary: 15,
        },
      },
    });
    // shallowRef 定义基本数据类型时和ref用法一样
    let x = shallowRef({
      y: 0,
    });

    console.log("x :>> ", x);

    return {
      person,
      x,
      ...toRefs(person),
    };
  },
};
</script>
